#include "rendPlatform.hpp"
#include "rendLight.hpp"

#include <math.h>

namespace rend
{

Light::Light()
: mAmbient(0.f, 0.f, 0.f)
, mDiffuse(1.f, 1.f, 1.f)
, mSpecular(1.f, 1.f, 1.f)
, mPosition(0.f, 0.f, 1.f, 0.f)
, mSpotDirection(0.f, 0.f, -1.f)
, mSpotExponent(0.f)
, mSpotCutoff(M_PI)
, mAttenuConstant(1.f)
, mAttenuLinear(0.f)
, mAttenuQuadratic(0.f)
{}


void Light::setAmbient(const ColorA& color)
{
	mAmbient = color;
}


const ColorA& Light::getAmbient() const
{
	return mAmbient;
}


void Light::setDiffuse(const ColorA& color)
{
	mDiffuse = color;
}


const ColorA& Light::getDiffuse() const
{
	return mDiffuse;
}


void Light::setSpecular(const ColorA& color)
{
	mSpecular = color;
}


const ColorA& Light::getSpecular() const
{
	return mSpecular;
}


void Light::setPosition(const vect4& position)
{
	mPosition = position;
}


const vect4& Light::getPosition() const
{
	return mPosition;
}


void Light::setSpotDirection(const vect3& direction)
{
	mSpotDirection = direction;
}


const vect3& Light::getSpotDirection() const
{
	return mSpotDirection;
}


void Light::setSpotExponent(const float exp)
{
	assert(exp >= 0.f && exp <= 128.f);

	mSpotExponent = exp;
}


float Light::getSpotExponent() const
{
	return mSpotExponent;
}


void Light::setSpotCutoff(const float angle)
{
	assert(angle >= 0.f && angle <= float(M_PI_2) || angle == float(M_PI));

	mSpotCutoff = angle;
}


float Light::getSpotCutoff() const
{
	return mSpotCutoff;
}


void Light::setAttenuConstant(const float factor)
{
	assert(factor >= 0.f);

	mAttenuConstant = factor;
}


float Light::getAttenuConstant() const
{
	return mAttenuConstant;
}


void Light::setAttenuLinear(const float factor)
{
	assert(factor >= 0.f);

	mAttenuLinear = factor;
}


float Light::getAttenuLinear() const
{
	return mAttenuLinear;
}


void Light::setAttenuQuadratic(const float factor)
{
	assert(factor >= 0.f);

	mAttenuQuadratic = factor;
}



float Light::getAttenuQuadratic() const
{
	return mAttenuQuadratic;
}

} // namespace rend
